import { renderToPipeableStream,renderToString } from 'react-dom/server';
import { StaticRouter } from 'react-router-dom/server';
import Html from './Html';
import App from './Router'


export async function render(url, res) {

  const { pipe } = renderToPipeableStream(
    <Html>
      <StaticRouter location={url}>
        <App />
      </StaticRouter>
     
    </Html>,
    {
      onShellReady() {
        res.setHeader('content-type', 'text/html');
        pipe(res);
      },
    }
  );
}

export const renderDev = async (url)=>{

  return renderToString(
    <StaticRouter location={url}>
      <App/>
    </StaticRouter>
  );
}